import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.junit.Test;

import javax.sql.DataSource;
import java.sql.Connection;
import java.util.Properties;

public class 连接池 {
    private static DataSource dataSource = null;

    static {
        try {
            Properties properties = new Properties();
            properties.load(连接池.class.getClassLoader().getResourceAsStream("resources/druid.properties"));
            dataSource = DruidDataSourceFactory.createDataSource(properties);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void 德鲁伊() throws Exception {
        Properties properties = new Properties();
        properties.load(连接池.class.getClassLoader().getResourceAsStream("resources/druid.properties"));

        DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);

        Connection connection = dataSource.getConnection();
        System.out.println(connection);
        connection.close();
    }

    public static Connection getConnection() throws Exception {

        Connection connection = dataSource.getConnection();
        return connection;
    }

}
